######################################################################################
#
# This file was provided as part of the SharePoint Mystery Deployment package
# Created by Christopher Kimbell (http://sharepointmystery.com)
#
######################################################################################

# -----------------------------------------------------------------
# Creates an object used to manipulate the blob cache
# -----------------------------------------------------------------
function New-BlobCache()
{
    $obj=new-object PSObject -Property @{
        Location = "";
        Path = "\.(gif|jpg|jpeg|jpe|jfif|bmp|dib|tif|tiff|ico|png|wdp|hdp|css|js|asf|avi|flv|m4v|mov|mp3|mp4|mpeg|mpg|rm|rmvb|wma|wmv)$";
        MaxSize = 20;
        Enabled = $false;
        WebApplication = $null;
    }
    # -----------------------------------------------------------------
    # Configures the blob cache
    # -----------------------------------------------------------------
    Add-Method $obj "CreateDirectory" `
    {
        New-SPMServerDirectory -Path $this.Location -Servers $farm.Servers
    }
    # -----------------------------------------------------------------
    # Configures the blob cache
    # -----------------------------------------------------------------
    Add-Method $obj "Configure" `
    {
        Set-SPMBlobCache -Identity $this.WebApplication.DefaultZone.AbsoluteUrl `
            -Location $this.Location `
            -MaxSize $this.MaxSize `
            -Path $this.Path `
            -Enabled:$this.Enabled
     }
     return $obj
}
